<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <el-table :data="tableData" class="u-mt-10" v-viewer @selection-change="handleSelectionChange">
        <el-table-column label="序号" type="index" :index="getIndexNo" width="60"></el-table-column>
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column label="标题" prop="title"></el-table-column>
        <el-table-column label="类型" prop="type">
            <template slot-scope="scope">
                {{scope.row.type==1?'图文':scope.row.type==2?'视频':'未分类'}}
            </template>
        </el-table-column>
        <el-table-column label="状态">
          <template slot-scope="scope">
              {{scope.row.status?'上线':'下线'}}
            <!-- <el-switch
              v-model="scope.row.status"
              :active-value="1"
              :inactive-value="0"
              active-color="#13ce66"
              @change="handleStatus(scope.row.id,scope.row.status)"
            ></el-switch> -->
          </template>
        </el-table-column>
        <el-table-column label="仅会员可见">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.is_member==1">否</el-tag>
            <el-tag type="success" v-if="scope.row.is_member==2">是</el-tag>
          </template>
        </el-table-column>
        <!-- <el-table-column label="排序" prop="sort"></el-table-column> -->
        <el-table-column label="创建时间" prop="create_time" sortable></el-table-column>
      </el-table>

      <div class="u-mt-20 u-text-center">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handlePageChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="limit"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
import commonPage from "@/mixins/common-page";

export default {
  mixins: [commonPage],
  props:{
      objform:{
          type:Object,
          default: function () {
              return {}
          }
      },
      apiPageName:{
          type:String,
          default:'page2'
      },
      queryFormIdName:{
          type:String,
          default:'id'
      }
  },
  data() {
    return {
      apiName: "companyArticle",
      queryForm: {
        status: "",
        is_hot: "",
        keyword: "",
      },
      apiPage:'page2',
      queryFormId:'id'

    };
  },
  methods:{
      getPageData2(){
          this.getPageData(true)
      },
      handleSelectionChange(val) {
          let arr=[]
        val.map((item) => {
          arr.push(item.id);
        });
        this.$emit('onChecked',arr)
      },
  },
  watch: {
      objform:{
          deep: true,
          immediate: true,
          handler(val){
              this.queryForm.keyword=val.keyword
          }
      },
      apiPageName:{
          deep: true,
          immediate: true,
          handler(val){
              this.apiPage=val
          }
      },
      queryFormIdName:{
        deep: true,
        immediate: true,
        handler(val){
            this.queryFormId=val
        }
      }
  },
};
</script>
